/**
 * 在线留言
 */
layui.use(['form', 'layer','jquery'],function () {
    $ = layui.jquery;
    var form = layui.form;
    var layer = layui.layer;

    //监听提交
    form.on('submit(add)', function (data) {
        // console.log(data.field);
        //发异步，把数据提交给Java
        $.ajax({
            type: 'post',
            url: requestURL+prefix+elseService+'/qiantai/onlineMessage',
            data: JSON.stringify(data.field),
            contentType: 'application/json;charset=utf-8',
            dataType: 'json',
            success: function (res) {
                if (res.status == 200 ) {
                    $("#sumbit").attr("disabled",true); //禁止点击按钮
                    layer.msg("留言成功！", {icon: 1, time: 1100,end:function () {
                            // 可以对表单进行重置
                            $("#messageForm")[0].reset();
                        }});
                    return false;
                }
                layer.msg('留言失败！', {icon: 2, time: 1200});
                return false;
            },
            error: function () {
                layer.msg('请求接口异常！', {icon: 0, time: 1200});
                return false;
            }

        });
        return false;
    });
})